From d73a110d369068d0d28eb079af7620bd65032f79 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 24 Jan 2015 22:03:42 -0800 Subject: [PATCH] Update to rust 2015-01-24 --- Cargo.lock | 38 ++++++++++----------- src/bin/cargo.rs | 6 ++-- src/cargo/core/package_id.rs | 4 +-- src/cargo/core/shell.rs | 2 +- src/cargo/core/source.rs | 4 +-- src/cargo/lib.rs | 43 ++++++++---------------- src/cargo/ops/cargo_package.rs | 2 +- src/cargo/ops/cargo_read_manifest.rs | 4 +-- src/cargo/ops/cargo_rustc/fingerprint.rs | 2 +- src/cargo/ops/cargo_rustc/mod.rs | 4 +-- src/cargo/sources/git/source.rs | 2 +- src/cargo/sources/path.rs | 15 +++++---- src/cargo/sources/registry.rs | 6 ++-- src/cargo/util/config.rs | 31 ++++++++++------- src/cargo/util/errors.rs | 36 ++++++++++---------- src/cargo/util/profile.rs | 2 +- src/rustversion.txt | 2 +- src/snapshots.txt | 8 +++++ tests/resolve.rs | 2 +- tests/support/mod.rs | 4 +-- tests/support/registry.rs | 4 +-- tests/test_cargo_bench.rs | 1 + tests/test_cargo_build_auth.rs | 6 ++-- tests/test_cargo_compile_custom_build.rs | 4 +-- tests/test_cargo_compile_plugins.rs | 4 +-- tests/test_cargo_publish.rs | 4 +-- tests/test_cargo_search.rs | 4 +-- tests/test_cargo_test.rs | 1 + 28 files changed, 124 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6832f1d2..ecf3bf05d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,20 +5,20 @@ dependencies = [ "advapi32-sys 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.31 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "glob 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)", "log 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "registry 0.1.0", "rustc-serialize 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tar 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -26,7 +26,7 @@ name = "advapi32-sys" version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -40,7 +40,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -51,7 +51,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -66,7 +66,7 @@ dependencies = [ [[package]] name = "flate2" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "miniz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -89,20 +89,20 @@ dependencies = [ [[package]] name = "glob" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hamcrest" version = "0.1.0" -source = "git+https://github.com/carllerche/hamcrest-rust.git#445dc78024c7d912d2e52dcd3ef3dfe2c8dbab47" +source = "git+https://github.com/carllerche/hamcrest-rust.git#69ac9ba5dc1c5bcd3219ab32d3bc5285c4e3a5c3" [[package]] name = "kernel32-sys" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -117,7 +117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libssh2-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -126,7 +126,7 @@ name = "libressl-pnacl-sys" version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pnacl-build-helper 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pnacl-build-helper 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -135,7 +135,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libz-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libressl-pnacl-sys 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -184,7 +184,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pnacl-build-helper" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -212,7 +212,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "tar" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -222,7 +222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -253,6 +253,6 @@ dependencies = [ [[package]] name = "winapi" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index e0f9ca4eb..33b5e9663 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -202,9 +202,9 @@ fn list_commands() -> BTreeSet { if filename.starts_with(command_prefix) && filename.ends_with(os::consts::EXE_SUFFIX) && is_executable(entry) { - let command = filename.slice( - command_prefix.len(), - filename.len() - os::consts::EXE_SUFFIX.len()); + let command = &filename[ + command_prefix.len().. + filename.len() - os::consts::EXE_SUFFIX.len()]; commands.insert(String::from_str(command)); } } diff --git a/src/cargo/core/package_id.rs b/src/cargo/core/package_id.rs index 9d999890f..d82ce75a4 100644 --- a/src/cargo/core/package_id.rs +++ b/src/cargo/core/package_id.rs @@ -92,8 +92,8 @@ impl Error for PackageIdError { } impl fmt::Display for PackageIdError { - fn fmt(self, f: fmt::Formatter) { - match self { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { PackageIdError::InvalidVersion(ref v) => { write!(f, "invalid version: {}", *v) } diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 5cdf2d117..46a5f8c2d 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -94,7 +94,7 @@ impl Shell { if config.tty && config.color { let term = TerminfoTerminal::new(out); term.map(|t| Shell { - terminal: Colored(t), + terminal: Colored(Box::new(t)), config: config }).unwrap_or_else(|| { Shell { terminal: NoColor(Box::new(stderr())), config: config } diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 4b5d017a2..b7c1c02a0 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -128,7 +128,7 @@ impl SourceId { SourceId::new(Kind::Registry, url) .with_precise(Some("locked".to_string())) } - "path" => SourceId::for_path(&Path::new(url.slice_from(5))).unwrap(), + "path" => SourceId::for_path(&Path::new(&url[5..])).unwrap(), _ => panic!("Unsupported serialized SourceId") } } @@ -285,7 +285,7 @@ impl fmt::Display for SourceId { match *precise { Some(ref s) => { - try!(write!(f, "#{}", s.as_slice().slice_to(8))); + try!(write!(f, "#{}", &s[..8])); } None => {} } diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 7c6f6ddc5..e141fd20a 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -107,7 +107,7 @@ pub fn process_executed(result: CliResult>, shell: &mut MultiShell) match result { Err(e) => handle_error(e, shell), Ok(Some(encodable)) => { - let encoded = json::encode(&encodable); + let encoded = json::encode(&encodable).unwrap(); println!("{}", encoded); } _ => {} @@ -134,16 +134,10 @@ pub fn shell(verbose: bool) -> MultiShell { // `output` print variant error strings to either stderr or stdout. // For fatal errors, print to stderr; // and for others, e.g. docopt version info, print to stdout. -fn output(caption: Option<&str>, detail: Option, - shell: &mut MultiShell, fatal: bool) { +fn output(err: String, shell: &mut MultiShell, fatal: bool) { let std_shell = if fatal {shell.err()} else {shell.out()}; - if let Some(caption) = caption { - let color = if fatal {RED} else {BLACK}; - let _ = std_shell.say(caption, color); - } - if let Some(detail) = detail { - let _ = std_shell.say(detail, BLACK); // always black - } + let color = if fatal {RED} else {BLACK}; + let _ = std_shell.say(err, color); } pub fn handle_error(err: CliError, shell: &mut MultiShell) { @@ -153,17 +147,13 @@ pub fn handle_error(err: CliError, shell: &mut MultiShell) { let fatal = exit_code != 0; // exit_code == 0 is non-fatal error - let desc = error.description(); - let hide_desc = unknown && !shell.get_verbose(); - if hide_desc { - output(Some("An unknown error occurred"), None, shell, fatal); - } else if desc.len() > 0 { - output(Some(desc), None, shell, fatal); + let hide = unknown && !shell.get_verbose(); + if hide { + let _ = shell.err().say("An unknown error occurred", RED); + } else { + output(error.to_string(), shell, fatal); } - if shell.get_verbose() { - output(None, error.detail(), shell, fatal); - } - if !handle_cause(&*error, shell) || (hide_desc && !desc.is_empty()) { + if !handle_cause(&*error, shell) || hide { let _ = shell.err().say("\nTo learn more, run the command again \ with --verbose.".to_string(), BLACK); } @@ -180,23 +170,18 @@ fn handle_cause(mut cargo_err: &CargoError, shell: &mut MultiShell) -> bool { None => { err = cargo_err.cause(); break } }; if !verbose && !cargo_err.is_human() { return false } - print(cargo_err.description(), cargo_err.detail(), shell); + print(cargo_err.to_string(), shell); } loop { let cause = match err { Some(err) => err, None => return true }; if !verbose { return false } - print(cause.description(), cause.detail(), shell); + print(cause.to_string(), shell); err = cause.cause(); } - fn print(desc: &str, detail: Option, shell: &mut MultiShell) { + fn print(error: String, shell: &mut MultiShell) { let _ = shell.err().say("\nCaused by:", BLACK); - let _ = shell.err().say(format!(" {}", desc), BLACK); - if shell.get_verbose() { - if let Some(detail) = detail { - let _ = shell.err().say(detail, BLACK); - } - } + let _ = shell.err().say(format!(" {}", error), BLACK); } } diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index e158ccd31..d7ed2bcd1 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -87,7 +87,7 @@ fn check_metadata(pkg: &Package, config: &Config) -> CargoResult<()> { lacking!(description, license || license_file, documentation || homepage || repository); if !missing.is_empty() { - let mut things = missing.slice_to(missing.len() - 1).connect(", "); + let mut things = missing[..missing.len() - 1].connect(", "); // things will be empty if and only if length == 1 (i.e. the only case to have no `or`). if !things.is_empty() { things.push_str(" or "); diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 3dc1aba68..9c6b50b0d 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -13,8 +13,8 @@ pub fn read_manifest(contents: &[u8], layout: Layout, source_id: &SourceId, -> CargoResult<(Manifest, Vec)> { let root = layout.root.clone(); util::toml::to_manifest(contents, source_id, layout, config).chain_error(|| { - human(format!("failed to parse manifest at `{:?}`", - root.join("Cargo.toml"))) + human(format!("failed to parse manifest at `{}`", + root.join("Cargo.toml").display())) }) } diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 7f765a354..95752de97 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -241,7 +241,7 @@ fn calculate_target_fresh(dep_info: &Path) -> CargoResult { internal(format!("dep-info not in an understood format: {}", dep_info.display())) })); - let deps = line.slice_from(pos + 2); + let deps = &line[pos + 2..]; let mut deps = deps.split(' ').map(|s| s.trim()).filter(|s| !s.is_empty()); loop { diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 2b9724847..20e72393a 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -67,7 +67,7 @@ pub fn rustc_old_version() -> CargoResult<(String, String)> { let triple = { let triple = output.as_slice().lines().filter(|l| { l.starts_with("host: ") - }).map(|l| l.slice_from(6)).next(); + }).map(|l| &l[6..]).next(); let triple = try!(triple.chain_error(|| { internal("rustc -v didn't have a line for `host:`") })); @@ -86,7 +86,7 @@ pub fn rustc_new_version() -> CargoResult<(String, String)> { let triple = { let triple = output.as_slice().lines().filter(|l| { l.starts_with("host: ") - }).map(|l| l.slice_from(6)).next(); + }).map(|l| &l[6..]).next(); let triple = try!(triple.chain_error(|| { internal("rustc -v didn't have a line for `host:`") })); diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 54c0064c4..405590dea 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -134,7 +134,7 @@ pub fn canonicalize_url(url: &Url) -> Url { if needs_chopping { let last = rel.path.pop().unwrap(); let last = last.as_slice(); - rel.path.push(last.slice_to(last.len() - 4).to_string()) + rel.path.push(last[..last.len() - 4].to_string()) } } _ => {} diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index b27b31c3c..3fc6990f2 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -74,12 +74,15 @@ impl<'a, 'b> PathSource<'a, 'b> { pub fn list_files(&self, pkg: &Package) -> CargoResult> { let root = pkg.get_manifest_path().dir_path(); - let exclude = pkg.get_manifest().get_exclude().iter().map(|p| { - Pattern::new(p.as_slice()) - }).collect::>(); - let include = pkg.get_manifest().get_include().iter().map(|p| { - Pattern::new(p.as_slice()) - }).collect::>(); + let parse = |&: p: &String| { + Pattern::new(p.as_slice()).map_err(|e| { + human(format!("could not parse pattern `{}`: {}", p, e)) + }) + }; + let exclude = try!(pkg.get_manifest().get_exclude().iter() + .map(|p| parse(p)).collect::, _>>()); + let include = try!(pkg.get_manifest().get_include().iter() + .map(|p| parse(p)).collect::, _>>()); let mut filter = |&mut: p: &Path| { let relative_path = p.path_relative_from(&root).unwrap(); diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs index 6f0542f94..d3e311cf1 100644 --- a/src/cargo/sources/registry.rs +++ b/src/cargo/sources/registry.rs @@ -367,9 +367,9 @@ impl<'a, 'b> RegistrySource<'a, 'b> { let path = match fs_name.len() { 1 => path.join("1").join(fs_name), 2 => path.join("2").join(fs_name), - 3 => path.join("3").join(fs_name.slice_to(1)).join(fs_name), - _ => path.join(fs_name.slice(0, 2)) - .join(fs_name.slice(2, 4)) + 3 => path.join("3").join(&fs_name[..1]).join(fs_name), + _ => path.join(&fs_name[0..2]) + .join(&fs_name[2..4]) .join(fs_name), }; let summaries = match File::open(&path) { diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index f7c64d982..40cca9153 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -114,10 +114,11 @@ impl<'a> Config<'a> { CV::Boolean(_, ref path) => { let idx = key.split('.').take(i) .fold(0, |n, s| n + s.len()) + i - 1; - let key_so_far = key.slice_to(idx); + let key_so_far = &key[..idx]; return Err(human(format!("expected table for configuration \ - key `{}`, but found {} in {:?}", - key_so_far, val.desc(), path))); + key `{}`, but found {} in {}", + key_so_far, val.desc(), + path.display()))); } } } @@ -163,13 +164,13 @@ impl<'a> Config<'a> { let contents = try!(file.read_to_string()); let table = try!(cargo_toml::parse(contents.as_slice(), &path).chain_error(|| { - human(format!("could not parse TOML configuration in `{:?}`", - path)) + human(format!("could not parse TOML configuration in `{}`", + path.display())) })); let toml = toml::Value::Table(table); let value = try!(CV::from_toml(&path, toml).chain_error(|| { - human(format!("failed to load TOML configuration from `{:?}`", - path)) + human(format!("failed to load TOML configuration from `{}`", + path.display())) })); try!(cfg.merge(value)); Ok(()) @@ -202,16 +203,19 @@ pub enum ConfigValue { impl fmt::Debug for ConfigValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - CV::Integer(i, ref path) => write!(f, "{} (from {:?})", i, path), - CV::Boolean(b, ref path) => write!(f, "{} (from {:?})", b, path), - CV::String(ref s, ref path) => write!(f, "{} (from {:?})", s, path), + CV::Integer(i, ref path) => write!(f, "{} (from {})", i, + path.display()), + CV::Boolean(b, ref path) => write!(f, "{} (from {})", b, + path.display()), + CV::String(ref s, ref path) => write!(f, "{} (from {})", s, + path.display()), CV::List(ref list, ref path) => { try!(write!(f, "[")); for (i, &(ref s, ref path)) in list.iter().enumerate() { if i > 0 { try!(write!(f, ", ")); } try!(write!(f, "{} (from {})", s, path.display())); } - write!(f, "] (from {:?})", path) + write!(f, "] (from {})", path.display()) } CV::Table(ref table, _) => write!(f, "{:?}", table), } @@ -357,8 +361,9 @@ impl ConfigValue { } fn expected(&self, wanted: &str) -> CargoResult { - Err(internal(format!("expected a {}, but found a {} in {:?}", - wanted, self.desc(), self.definition_path()))) + Err(internal(format!("expected a {}, but found a {} in {}", + wanted, self.desc(), + self.definition_path().display()))) } fn into_toml(self) -> toml::Value { diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 32f65372a..c738ed70f 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -17,17 +17,11 @@ pub type CargoResult = Result>; // ============================================================================= // CargoError trait -pub trait CargoError: Error { +pub trait CargoError: Error + Send { fn is_human(&self) -> bool { false } fn cargo_cause(&self) -> Option<&CargoError>{ None } } -impl fmt::Display for Box { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "{}", self.description())); - Ok(()) - } -} impl fmt::Debug for Box { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) @@ -91,8 +85,8 @@ impl Error for ChainedError { } impl fmt::Display for ChainedError { - fn fmt(&self, f: fmt::Formatter) { - fmt::Display::fmt(self.error, f) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.error, f) } } @@ -135,13 +129,17 @@ impl fmt::Debug for ProcessError { struct ConcreteCargoError { description: String, detail: Option, - cause: Option>, + cause: Option>, is_human: bool, } impl fmt::Display for ConcreteCargoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.description) + try!(write!(f, "{}", self.description)); + if let Some(ref s) = self.detail { + try!(write!(f, " ({})", s)); + } + Ok(()) } } impl fmt::Debug for ConcreteCargoError { @@ -153,7 +151,9 @@ impl fmt::Debug for ConcreteCargoError { impl Error for ConcreteCargoError { fn description(&self) -> &str { self.description.as_slice() } fn cause(&self) -> Option<&Error> { - self.cause.as_ref().map(|c| &**c) + self.cause.as_ref().map(|c| { + let e: &Error = &**c; e + }) } } @@ -174,8 +174,8 @@ impl Error for Human { } impl fmt::Display for Human { - fn fmt(self, f: fmt::Formatter) { - fmt::Display::fmt(self.0, f) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.0, f) } } @@ -202,8 +202,8 @@ impl Error for CliError { } impl fmt::Display for CliError { - fn fmt(self, f: fmt::Formatter) { - fmt::Display::fmt(self.error, f) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.error, f) } } @@ -330,11 +330,11 @@ pub fn human(error: S) -> Box { }) } -pub fn caused_human(error: S, cause: E) -> Box { +pub fn caused_human(error: S, cause: E) -> Box { Box::new(ConcreteCargoError { description: error.to_string(), detail: None, - cause: Some(Box::new(cause) as Box), + cause: Some(Box::new(cause) as Box), is_human: true }) } diff --git a/src/cargo/util/profile.rs b/src/cargo/util/profile.rs index c2a932b71..c5aa87ed4 100644 --- a/src/cargo/util/profile.rs +++ b/src/cargo/util/profile.rs @@ -42,7 +42,7 @@ impl Drop for Profiler { println!("{} {:6}ms - {}", repeat(" ").take(lvl + 1).collect::(), time / 1000000, msg); - print(lvl + 1, msgs.slice(last, i)); + print(lvl + 1, &msgs[last..i]); last = i; } diff --git a/src/rustversion.txt b/src/rustversion.txt index 428e67a0a..05c8f09f6 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2015-01-18 +2015-01-24 diff --git a/src/snapshots.txt b/src/snapshots.txt index 29ab02253..b95d4da6d 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +2015-01-24 + linux-i386 96213038f850569f1c4fa6a0d146c6155c0d566b + linux-x86_64 4d87486493c2881edced7b1d2f8beaac32aaa5b5 + macos-i386 17b9fc782e86bffe170abb83a01e0cb7c90a0daa + macos-x86_64 18887bdbd3e6d2a127aa34216fa06e9877b0fbc6 + winnt-i386 10b9b5fa3e9241ef0b6c3b77b0c072a45b585905 + winnt-x86_64 ba71627e46964535b64da56bd0679e5f86fae957 + 2014-12-30 linux-i386 ab8bba0918d3d2ddbd7fd21f147e223dbf04cece linux-x86_64 0efe0f7bcbcbeb5494affcc8a2207db448a08c45 diff --git a/tests/resolve.rs b/tests/resolve.rs index 9dcd97219..3198adcec 100644 --- a/tests/resolve.rs +++ b/tests/resolve.rs @@ -334,7 +334,7 @@ fn resolving_but_no_exists() { ], &mut reg); assert!(res.is_err()); - assert_eq!(res.unwrap_err().to_string(), "\ + assert_eq!(res.err().unwrap().to_string(), "\ no matching package named `foo` found (required by `root`) location searched: registry http://example.com/ version required: ^1\ diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 052dcedef..4a814821e 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -349,7 +349,7 @@ impl Execs { fn lines_match(expected: &str, mut actual: &str) -> bool { for part in expected.split_str("[..]") { match actual.find_str(part) { - Some(i) => actual = actual.slice_from(i + part.len()), + Some(i) => actual = &actual[i + part.len()..], None => { return false } @@ -485,7 +485,7 @@ pub fn basic_lib_manifest(name: &str) -> String { } pub fn path2url(p: Path) -> Url { - Url::from_file_path(&p).unwrap() + Url::from_file_path(&p).ok().unwrap() } pub static RUNNING: &'static str = " Running"; diff --git a/tests/support/registry.rs b/tests/support/registry.rs index dbd8164c7..4c3a2be18 100644 --- a/tests/support/registry.rs +++ b/tests/support/registry.rs @@ -13,9 +13,9 @@ use support::git::repo; use cargo::util::Sha256; pub fn registry_path() -> Path { paths::root().join("registry") } -pub fn registry() -> Url { Url::from_file_path(®istry_path()).unwrap() } +pub fn registry() -> Url { Url::from_file_path(®istry_path()).ok().unwrap() } pub fn dl_path() -> Path { paths::root().join("dl") } -pub fn dl_url() -> Url { Url::from_file_path(&dl_path()).unwrap() } +pub fn dl_url() -> Url { Url::from_file_path(&dl_path()).ok().unwrap() } pub fn init() { let config = paths::home().join(".cargo/config"); diff --git a/tests/test_cargo_bench.rs b/tests/test_cargo_bench.rs index 3108b0bc2..bad1e62e5 100644 --- a/tests/test_cargo_bench.rs +++ b/tests/test_cargo_bench.rs @@ -185,6 +185,7 @@ test bench_hello ... ", thread '
' panicked at 'assertion failed: \ `(left == right) && (right == left)` (left: \ `\"hello\"`, right: `\"nope\"`)', src{sep}foo.rs:14 + ", sep = path::SEP)) .with_status(101)); }); diff --git a/tests/test_cargo_build_auth.rs b/tests/test_cargo_build_auth.rs index 048ad3d3d..ff6bdf699 100644 --- a/tests/test_cargo_build_auth.rs +++ b/tests/test_cargo_build_auth.rs @@ -164,10 +164,10 @@ Caused by: ", addr = addr, errmsg = if cfg!(windows) { - "failed to send request: The connection with the server \ + "[[..]] failed to send request: The connection with the server \ was terminated abnormally\n" } else { - "SSL error: [..]" + "[[..]] SSL error: [..]" }))); t.join().ok().unwrap(); @@ -210,7 +210,7 @@ Caused by: failed to clone into: [..] Caused by: - Failed to start SSH session: Failed getting banner + [[..]] Failed to start SSH session: Failed getting banner ", addr = addr))); t.join().ok().unwrap(); diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index 361f41171..b339a1262 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -1031,8 +1031,8 @@ test!(build_script_with_dynamic_native_dependency { lib.ends_with(os::consts::DLL_SUFFIX) }).unwrap(); let libname = lib.filename_str().unwrap(); - let libname = libname.slice(os::consts::DLL_PREFIX.len(), - libname.len() - os::consts::DLL_SUFFIX.len()); + let libname = &libname[os::consts::DLL_PREFIX.len().. + libname.len() - os::consts::DLL_SUFFIX.len()]; let foo = project("foo") .file("Cargo.toml", r#" diff --git a/tests/test_cargo_compile_plugins.rs b/tests/test_cargo_compile_plugins.rs index c246e854f..d20714cb7 100644 --- a/tests/test_cargo_compile_plugins.rs +++ b/tests/test_cargo_compile_plugins.rs @@ -107,8 +107,8 @@ test!(plugin_with_dynamic_native_dependency { lib.ends_with(os::consts::DLL_SUFFIX) }).unwrap(); let libname = lib.filename_str().unwrap(); - let libname = libname.slice(os::consts::DLL_PREFIX.len(), - libname.len() - os::consts::DLL_SUFFIX.len()); + let libname = &libname[os::consts::DLL_PREFIX.len().. + libname.len() - os::consts::DLL_SUFFIX.len()]; let foo = project("foo") .file("Cargo.toml", r#" diff --git a/tests/test_cargo_publish.rs b/tests/test_cargo_publish.rs index ab35614b6..62b5f129e 100644 --- a/tests/test_cargo_publish.rs +++ b/tests/test_cargo_publish.rs @@ -12,9 +12,9 @@ use support::git::repo; use hamcrest::assert_that; fn registry_path() -> Path { paths::root().join("registry") } -fn registry() -> Url { Url::from_file_path(®istry_path()).unwrap() } +fn registry() -> Url { Url::from_file_path(®istry_path()).ok().unwrap() } fn upload_path() -> Path { paths::root().join("upload") } -fn upload() -> Url { Url::from_file_path(&upload_path()).unwrap() } +fn upload() -> Url { Url::from_file_path(&upload_path()).ok().unwrap() } fn setup() { let config = paths::root().join(".cargo/config"); diff --git a/tests/test_cargo_search.rs b/tests/test_cargo_search.rs index 6a9462eae..e265bbbb4 100644 --- a/tests/test_cargo_search.rs +++ b/tests/test_cargo_search.rs @@ -11,9 +11,9 @@ use support::git::repo; use hamcrest::assert_that; fn registry_path() -> Path { paths::root().join("registry") } -fn registry() -> Url { Url::from_file_path(®istry_path()).unwrap() } +fn registry() -> Url { Url::from_file_path(®istry_path()).ok().unwrap() } fn api_path() -> Path { paths::root().join("api") } -fn api() -> Url { Url::from_file_path(&api_path()).unwrap() } +fn api() -> Url { Url::from_file_path(&api_path()).ok().unwrap() } fn setup() { let config = paths::root().join(".cargo/config"); diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index f9478626f..e9e833a22 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -151,6 +151,7 @@ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured sep = path::SEP)) .with_stderr(format!("\ thread '
' panicked at 'Some tests failed', [..] + ")) .with_status(101)); }); -- 2.30.2